import 'package:flutter/material.dart';
import '../../model/my_store.dart';
import 'package:dio/dio.dart';
// widget 模块
import './user_info.dart';
import './opt_list.dart';
import './bottom_opt.dart';

import '../../model/config.dart';

class MyDrawer extends StatefulWidget {
  MyDrawer({
    Key key,
    this.setTheme,
    this.csuser,
    this.openCallback,
    this.onRefresh
  }):super(key: key);
  dynamic setTheme;
  Function openCallback;
  Function onRefresh;
  Map csuser;
  __MyDrawerState createState() => __MyDrawerState();
}

class __MyDrawerState extends State<MyDrawer> {
  int testType;
  Map csuser;
  @override
  void initState () {
    super.initState();
    widget.openCallback(true);
    testType = 1;
    csuser = widget.csuser;
  }
  @override
  void dispose () {
    super.dispose();
    widget.openCallback(false);
  }
  @override

  Widget build(BuildContext context) {
    return Drawer(
      semanticLabel: '客服详情',
      child: Column(
        children: <Widget>[
          DrawerUserInfo(
            csuser: csuser,
          ), // 用户详情
          DrawerOptList(
            cs_id: 1,
            setTheme:widget.setTheme
          ), // 操作列表
          DrawerBottomOpt(
            type: csuser['type'],
            status: csuser['status'],
            changeType: (int type) {
              print(type); 
              setState(() {testType = type;});
            },
            onRefresh: () {
              widget.onRefresh(csuser['id']);
              // refreshCsuser(csuser['id']);
            },
          )
        ],
      ),
    );
  }
}